package com.my.h2.logs;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;

/**
 * @author timo 2021/2/25
 */

// 映射超类：仅用于被继承，自身不生成表
@MappedSuperclass
@Data
@NoArgsConstructor
@AllArgsConstructor
public class LogAbstract implements Serializable {
    protected static final long serialVersionUID = 1L;
    @JsonSerialize(
            using = ToStringSerializer.class
    )
//    @TableId(
//            value = "id",
//            type = IdType.ASSIGN_ID
//    )
//    @Id
//    @GeneratedValue(strategy = GenerationType.IDENTITY)
//    protected Long id;
//    private String tenantId;
    @Column
    protected String serviceId;
    @Column
    protected String serverIp;
    @Column
    protected String serverHost;
    @Column
    protected String env;
    protected String remoteIp;
    @Column
    protected String userAgent;
    @Column
    protected String requestUri;
    @Column
    protected String method;
    @Column
    protected String methodClass;
    @Column
    protected String methodName;
    @Column
    protected String params;


    @Column(columnDefinition = "LONGTEXT")
    private String requestHeaders;
    @Column(columnDefinition = "LONGTEXT")
    private String responseHeaders;
    @Column
    private String requestUrl;
    @Column(columnDefinition = "LONGTEXT")
    private String result;

    @Column
    protected String createBy;
    @DateTimeFormat(
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    @Column
    protected Date createTime;


}
